package study.函数式接口;

import study.User;
import study.Utils;

import java.util.List;
import java.util.concurrent.Callable;
import java.util.function.Predicate;

/**
 * @Author 金贵权
 * @Date 2023/6/13 15:05
 **/
public class Demo01 {
    public static void main(String[] args) throws Exception {
        List<User> userList = Utils.getUserList();
        Predicate<List<User>> p = users->userList.get(0).getId() == 1;
        boolean test = p.test(userList);
        System.out.println(test);

        /*return方式*/
        Demo01 demo01 = new Demo01();
        Callable<String> fetch = demo01.fetch();
        String call = fetch.call();
        System.out.println(call);

        /*=方式*/
        Callable<String> test01 = ()->"下午好";
        String call1 = test01.call();
        System.out.println(call1);

        /*传参方式*/
        demo01.execute(()->{
            System.out.println("It is good.");
        });
    }

    public Callable<String> fetch(){
        return ()->"你好啊";
    }

    public void execute(Runnable run){
        System.out.println("俺也不想");
        run.run();
    }
}
